<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 判断一个对象是否为数组
      function isArray(arg) {
        if (typeof arg === 'object') {
          return Object.prototype.toString.call(arg) === '[object Array]';
        }
        return false;
      }
      var arr = [];
      var obj = {};
      console.log(isArray(arr)); //true
      console.log(isArray(obj)); //false
    </script>
  </body>
</html>
